import Vue from 'vue'
import Router from 'vue-router'
import {getToken} from '@/utils/auth'

Vue.use(Router)

const whitePage = ['/Home'];

export const baseRoutes = [
  {
    path: '/',
    redirect: '/Home'
  },
  {
    path: '/Home',
    component: () => import('@/views/Home.vue'),
    name: 'Home',
  }
];


const createRouter = () => new Router({
  routes: baseRoutes
});

const router = createRouter();
export default router

router.beforeEach((to, from, next) => {
  if (getToken()) {
    next()
  } else {
    location.href = window.SITE_CONFIG.cas.loginUrl + "?appId=" + window.SITE_CONFIG.appId
  }
});
